*Last updated:* 2025-06-17

*Purpose:* This repository contains the replication materials for the article, "Parents, Peers, and Political Participation: Social Influence among Roommates" published in the British Journal of Political Science

*Contact:* For questions or suggestions, please contact Matt Pietryka at matthew.pietryka@gmail.com

The analysis for this paper was conducted in R version 4.5.0 using the R scripts uploaded to this repository. See below for details about the R scripts and software versions.

# 1. Directory Structure ------------------

The replication files assume the following directory structure:

```
├── Analysis 1 - Compare Samples.R
├── Analysis 2 - Fit Regressions.R
├── Permutation Tests 1 - Randomize.R
├── Permutation Tests 2 - Summarize Outcomes.R
├── Permutation Tests 3 - Plots.R
├── Permutation Tests 4 - Placebo.R
├── Permutation Tests 5 - Gender Tables.R
├── Plot - Parents vs Roommates - by gender.R
├── Plot - Parents vs Roommates.R
├── Plot Preferences.R
├── data-files
│   ├── estimates_df.rds
│   ├── estimates_gender_df.rds
│   ├── gender_diff_df.rds
│   ├── id18_random_df.rds
│   ├── id18_selected_df.rds
│   ├── id18_term_random_df.rds
│   ├── indiv18_df.rds
│   ├── observed_dyads_df.rds
│   ├── replicates_df.rds
│   ├── replicates_unconstrained_df.rds
│   ├── room_affil_random_df.rds
│   ├── selected_dyads_df.rds
│   ├── stacked_df.rds
│   └── tufts-summary-v2.csv

```

To replicate these analyses, begin by creating this structure and setting the R working directory to the top level. Or modify all R scripts to correspond to the structure on your machine. 


# 2. file descriptions ------------------



* Analysis 1 - Compare Samples.R
    * Purpose: Produce Tables 1-3 (descriptive stats for full sample and subsamples)
    * Note: The script provides the code for Table 1, but we cannot share the data b/c it could
            be used to identify individual participants

* Analysis 2 - Fit Regressions.R
    * Purpose: Produce Table S1 (Appendix D: Regression Models)

* Permutation Tests 1 - Randomize.R
    * Purpose:  Permute the data 

* Permutation Tests 2 - Summarize Outcomes.R
    * Purpose:  Summarize the permutations

* Permutation Tests 3 - Plots.R
    * Purpose:  Produce Figure 3 (Observed vs Permuted Turnout Similarity Between Roommates)

* Permutation Tests 4 - Placebo.R
    * Purpose:  Produce Table 4 (Placebo Tests)

* Permutation Tests 5 - Gender Tables.R
    * Purpose:  Produce Table 5 (Comparing Women and Men in Turnout Similarity)

* Plot - Parents vs Roommates.R
    * Purpose:  Produce Figure 4 (Comparing peers and parents)

* Plot - Parents vs Roommates - by gender.R  
    * Purpose:  Produce Figure 5 (Comparing peers and parents, by gender)

* Plot Preferences.R
    * Purpose: code used in multiple scripts above to format tables and plots


# 3. Software details ------------------

Results may differ using different versions of R or R packages. The results reported in the paper were produced on a machine with the session info, below.

```

R version 4.5.0 (2025-04-11 ucrt)
Platform: x86_64-w64-mingw32/x64
Running under: Windows 11 x64 (build 26100)

Matrix products: default
  LAPACK version 3.12.1

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

time zone: America/Chicago
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
 [1] forcats_1.0.0      officer_0.6.10     flextable_0.9.9    ggplot2_3.5.2      furrr_0.3.1        future_1.58.0      showtext_0.9-7     showtextdb_3.0    
 [9] sysfonts_0.8.9     extrafont_0.19     glue_1.8.0         estimatr_1.0.6     gt_1.0.0           janitor_2.2.1      modelsummary_2.4.0 stringr_1.5.1     
[17] lubridate_1.9.4    purrr_1.0.4        readr_2.1.5        tidyr_1.3.1        dplyr_1.1.4       

loaded via a namespace (and not attached):
 [1] tidyselect_1.2.1        farver_2.1.2            fastmap_1.2.0           fontquiver_0.2.1        bayestestR_0.16.0       pandoc_0.2.0           
 [7] digest_0.6.37           timechange_0.3.0        lifecycle_1.0.4         magrittr_2.0.3          compiler_4.5.0          rlang_1.1.6            
[13] tools_4.5.0             data.table_1.17.4       knitr_1.50              askpass_1.2.1           bit_4.6.0               xml2_1.3.8             
[19] RColorBrewer_1.1-3      tinytable_0.9.0         withr_3.0.2             grid_4.5.0              datawizard_1.1.0        gdtools_0.4.2          
[25] extrafontdb_1.0         globals_0.18.0          scales_1.4.0            insight_1.3.0           cli_3.6.5               rmarkdown_2.29         
[31] crayon_1.5.3            ragg_1.4.0              generics_0.1.4          rstudioapi_0.17.1       performance_0.14.0      tzdb_0.5.0             
[37] parameters_0.26.0       parallel_4.5.0          vctrs_0.6.5             fontBitstreamVera_0.1.1 litedown_0.7            hms_1.1.3              
[43] bit64_4.6.0-1           Formula_1.2-5           listenv_0.9.1           systemfonts_1.2.3       parallelly_1.45.0       codetools_0.2-20       
[49] stringi_1.8.7           gtable_0.3.6            tables_0.9.31           tibble_3.3.0            pillar_1.10.2           rappdirs_0.3.3         
[55] htmltools_0.5.8.1       openssl_2.3.3           R6_2.6.1                textshaping_1.0.1       vroom_1.6.5             evaluate_1.0.3         
[61] backports_1.5.0         snakecase_0.11.1        fontLiberation_0.1.0    hrbrthemes_0.8.7        zip_2.3.3               uuid_1.2-1             
[67] Rcpp_1.0.14             Rttf2pt1_1.3.12         checkmate_2.3.2         xfun_0.52               fs_1.6.6                pkgconfig_2.0.3   

```



